package projectdemo01.operation;

import projectdemo01.book.Book;
import projectdemo01.book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:咭咭熊
 * Date:2021 - 09 - 23
 * Time:19:49
 */

/***
 * 归还图书——将图书的借阅状态修改为false即可
 */
public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还书籍");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要归还的图书名字：");
        String bookname = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(bookname)){
                //找到了书籍，将其状态修改为false
                book.setStatus(false);
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到要归还的书籍！");
    }
}
